<?php
$_order = (int) $_GET['order'];
$_classtype =(int) $_GET['classtype'];

$_orderArr = [
	0 => '默认',
	1 => '综合排序',//最热
	2 => '人气排序',
	3 => '开课时间排序',
];

$_classtypeArr = getcache(3360, 'linkage');
$_classtypeArr = $_classtypeArr['data'];

$sql = "select * from phpcms_classmany where status=99 and catid=$catid";
	if($_classtype){
	$sql .= " and classtype=$_classtype";
}
// TODO set order
switch ($_order) {
	case 1:
		$sql .= ' order by listorder desc,id desc';
		break;
	case 2:
		$sql .= ' order by num_view desc,id desc';
		break;
	case 3:
		$sql .= ' order by class_time1 desc,id desc';
		break;
	default:
		$sql .= ' order by listorder desc,id desc';
		break;
}
?>
{template "content","header"}

{template "content","header_nav_back_category"}

<div class="h_48"></div>
<!-- main -->
<main class="main">
	<ul class="navList1 clearfix">
		<li>
			<div class="nice-select">
				<input type="text" readonly="true" value="{if $_order!=0}{$_orderArr[$_order]}{else}综合排序{/if}" class="input1 j_down">
				<ul class="ul1">
					<li class="j_select{if $_order==0} on{/if}" data-type='order' data-value="0">默认排序</li>
					<li class="j_select{if $_order==2} on{/if}" data-type='order' data-value="2">人气排序</li>
					<li class="j_select{if $_order==3} on{/if}" data-type='order' data-value="3">开课时间排序</li>
				</ul>
			</div>
		</li>
		<li>
			<div class="nice-select">
				<input type="text" readonly="true" value="{if $_classtype!=0}{$_classtypeArr[$_classtype]['name']}{else}课程分类{/if}" class="input2 j_down">
				<ul class="ul1">
					<li class="j_select{if $_classtype==0} on{/if}" data-type='classtype' data-value="0">全部</li>
{loop $_classtypeArr $r}
					<li class="j_select{if $_classtype==$r[linkageid]} on{/if}" data-type='classtype' data-value="{$r[linkageid]}">{$r[name]}</li>
{/loop}
				</ul>
			</div>
		</li>
		<li class="hot"><a href="javascript:void(0);"><!-- <i></i> -->报名中</a></li>
	</ul>
	<ul class="oList10 clearfix">
{pc:get sql="$sql" page="$page"}
{loop $data $r}
		<li>
			{php $techer=getTeacherInfo($r[one_teacher])}
			<a href="{$r[url]}" class="oListTeacherImg"><img src="{$techer[thumb]}"></a>
			<div class="oListTeacher clearfix">主讲：{$techer[title]}
				<div class="btn_atten fr">
					<a href="javascript:void(0);" class="btn_attention js_like" data-catid="{$r[catid]}" data-id="{$r[id]}">收藏</a>
				</div>
			</div>
			<div class="oList10Con">
				<a href="{$r[url]}">
					<img style="width:100%;min-height:50px;" src="{$r[pic_push]}">
					<span class="black">仅剩名额： <em>{php echo $r[student_limit]-$r[student_has]}</em> </span>
				</a>
			</div>
			<div class="oList10Contxt">
				<a href="{$r[url]}">
					<div class="t55">{$r[title]}</div>
					<div class="con16 ellipsis">{$r[small_content]}</div>
					<div class="oList6Record clearfix">
						<span class="v_people fl">{date('Y-m-d',$r[class_time1])}</span>
						<span class="v_people3 fl">{$r[num_view]}</span>
						<span class="v_record fl">{$r[num_like]}</span>
						<span class="v_class fr">{get_linkage($r[classtype],3360,2)}</span>
					</div>
				</a>
			</div>
		</li>
{/loop}
{/pc}
	</ul>
	<!-- <div id="loading"></div>  -->
</main>
<!-- / main -->
<div class="h_48"></div>

<style type="text/css">
.nice-select input.j_down.on{background:#fff url({IMG_PATH2}icon/down2.png) no-repeat 100% 50%;background-size:8px;color:#32acdf;}
</style>
<script type="text/javascript">
var GET_PATH = '{GET_PATH}';
$(function(){
	//下拉选择
	var width1 = $(window).width();
	var height1 = $(window).height();
	$(".ul1").css({
		height: height1 + "px",
		width: '100%',
		background: "url({IMG_PATH2}icon/bg40.png) repeat"
	});
	$('.j_down').click(function(){
		$('.j_down').removeClass('on').next().hide();
		$(this).addClass('on').next().show();
	});
	$('.ul1').click(function(){
		$('.j_down').removeClass('on').next().hide();
	});
	$('.j_select').click(function(e){
		e.stopPropagation();
		var _this = $(this);
		var url = GET_PATH + '&' + _this.data('type')  + '=' + _this.data('value');
		location.href = url;
	});
});
</script>

{template "content","footer_nav"}

{template "content","footer"}